package org.rency.mq.kafka.producer.listener;

import org.apache.kafka.clients.producer.RecordMetadata;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.kafka.support.ProducerListener;

/**
 * 生产者监听器
 *
 * @author: Created by user_rcy@163.com on 2016/10/14.
 * @version: V1.0.0
 * @since JDK 1.8
 */
public class DefaultProducerListener implements ProducerListener<String,byte[]> {

    private static final Logger logger = LoggerFactory.getLogger(DefaultProducerListener.class);

    @Override
    public void onSuccess(String topic, Integer partition, String key, byte[] value, RecordMetadata recordMetadata) {
        logger.debug("Kafka producer event publish success, topic:{}, key:{}.",topic,key);
    }

    @Override
    public void onError(String topic, Integer partition, String key, byte[] value, Exception exception) {
        logger.error("Kafka producer event publish fail, topic:{}, key:{}, partition:{}.",topic,key,partition,exception);
    }

    @Override
    public boolean isInterestedInSuccess() {
        return false;
    }
}
